<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title></title>
		<style type="text/css">
			#div1{
				width: 100px;
				height: 100px;
			}
		</style>
	</head>
	<body>
		<div id="div1">
		</div>
		<button id="btn1" type="button" onclick="Start()">开Roll(直接出结果)</button>
		<button id="btn2" type="button" onclick="TenStart()">开Roll(摇色子)</button>
	</body>
	<script type="text/javascript">
		function Start(){
			Del();
			Add();
		};
		function TenStart(){
			var x=0;
			document.getElementById('btn1').innerText='抽奖中';
			document.getElementById('btn2').innerText='抽奖中';
			var MyInterval=setInterval(function(){
			Del();
			Add();
			if(x==60){
				clearInterval(MyInterval);
			}
			x++;
			},20
			);
			setTimeout( function(){
			document.getElementById('btn1').innerText='开Roll(直接出结果)';
			document.getElementById('btn2').innerText='开Roll(摇色子)';
			},1200);	
			};
			
		function Add(){
			var div1=document.getElementById('div1');
			var newdiv=document.createElement('div');
			newdiv.innerHTML=`
			<img width="100px" src="摇色子/`+random()+`.jpg" >
			`;
			div1.appendChild(newdiv);
		};
		function Del(){
			var div1=document.getElementById('div1');
			var div_img=document.getElementsByTagName('img');
			div1.removeChild(div_img[0].parentElement);
		};
		function random(){
			var x=Math.floor(Math. random()*6)+1;
			return x;
		};
		onload=function(){
		Add();
		}
	</script>
</html>
